home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / SciAn / src / ScianTitleBoxes.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  115 lines

  1. /* ScianTitleBoxes.c:    John R. Murray, 3-30-90
  2.         purely stylistic screen display objects.
  3. */
  4. #include "Scian.h"
  5. #include "ScianTypes.h"
  6. #include "ScianColors.h"
  7. #include "ScianIDs.h"
  8. #include "ScianErrors.h"
  9. #include "ScianArrays.h"
  10. #include "ScianWindows.h"
  11. #include "ScianObjWindows.h"
  12. #include "ScianFontSystem.h"
  13. #include "ScianStyle.h"
  14. #include "ScianDraw.h"
  15. #include "ScianControls.h"
  16. #include "ScianTextBoxes.h"
  17.  
  18. /* global define */
  19. ObjPtr    titleBoxClass;
  20.  
  21. /* local constants */
  22. #define LABELSPACER DEFTEXTSIZE    /* spacer from edge of box to start of text */
  23. #define LINESPACER  5.0        /* spacer in pixels from text to lines */
  24.  
  25. ObjPtr    DrawTitleBox(theTitleBox, theParent)
  26. ObjPtr    theTitleBox, theParent;
  27. {
  28.     int left, right, bottom, top;
  29.     int xText, yText;
  30.     ObjPtr   theLabel;
  31.     char        *label;
  32.     real    length;
  33.  
  34.     if (!Get2DIntBounds(theTitleBox, &left, &right, &bottom, &top))
  35.     {
  36.         return NULLOBJ;
  37.     }
  38.  
  39.     if (IsDrawingRestricted(left, right, bottom, top))
  40.     {
  41.     return ObjFalse;
  42.     }
  43.  
  44.     /* attempt to draw the title box label */
  45.     theLabel = GetVar(theTitleBox, NAME);
  46.     if (!theLabel)
  47.     {
  48.     DrawUILine(left, top, right, top, UITEXT);
  49.     DrawUILine(right, top, right, bottom, UITEXT);
  50.     DrawUILine(right, bottom, left, bottom, UITEXT);
  51.     DrawUILine(left, bottom, left, top, UITEXT);
  52.     }
  53.     else
  54.     {
  55.     if (!(theLabel = GetStringVar("DrawTitleBox", theTitleBox, NAME)))
  56.         {
  57.         label = "";
  58.         }
  59.     else
  60.     {
  61.             label = GetString(theLabel);
  62.     }
  63.         SetUIColor(UITEXT);
  64.     SetUIFont(DEFFONT);
  65.     DrawAString(LEFTALIGN, left + LABELSPACER, top - DEFTEXTSIZE, label);
  66.     length = StrWidth(label);
  67.  
  68.     /* Draw the box itself */
  69.     DrawUILine(
  70.         left + LABELSPACER - LINESPACER, top - DEFTEXTSIZE,
  71.         left, top - DEFTEXTSIZE, UITEXT);
  72.     DrawUILine(
  73.         left, top - DEFTEXTSIZE,
  74.         left, bottom, UITEXT);
  75.     DrawUILine(
  76.         left, bottom, right, bottom, UITEXT);
  77.     DrawUILine(right, bottom,
  78.         right, top - DEFTEXTSIZE, UITEXT);
  79.     DrawUILine(right, top - DEFTEXTSIZE,
  80.         left + length + LABELSPACER + LINESPACER, top - DEFTEXTSIZE, UITEXT);
  81.     }
  82. }
  83.  
  84. void    InitTitleBoxes()
  85. {
  86.     titleBoxClass = NewObject(controlClass, 0);
  87.     AddToReferenceList(titleBoxClass);
  88.     SetMethod(titleBoxClass, DRAW, DrawTitleBox);
  89. }
  90.  
  91. void    KillTitleBoxes()
  92. {
  93.     RemoveFromReferenceList(titleBoxClass);
  94.     titleBoxClass = 0;
  95. }
  96.  
  97. ObjPtr    NewTitleBox(left, right, bottom, top, title)
  98. int    left, right, bottom, top;
  99. char    *title;
  100. /* stylistic box with snazzy label */
  101. {
  102.     ObjPtr      retVal;
  103.     ObjPtr      labelPtr;
  104.  
  105.     retVal = NewObject(titleBoxClass, 0);
  106.     Set2DIntBounds(retVal, left, right, bottom, top);
  107.     if (title)
  108.     {
  109.     labelPtr = NewString(title);
  110.     SetVar(retVal, NAME, labelPtr);
  111.     }
  112.     return retVal;
  113. }
  114.  
  115.